import {createAsyncThunk, createSlice} from '@reduxjs/toolkit'
import axios from 'axios'
export const sea=createAsyncThunk(
    'sea',
    async ()=>{
        let res=await axios.get('http://localhost:3000/shop')
        return res.data
        
    }
)
const todo=createSlice({
    name:'todo',
    // 数据
    initialState:{
        shop:[]
    },
    // 方法
    reducers:{
        add(state,{payload}){

        }
    },
    extraReducers:{
        [sea.fulfilled]:(state,{payload})=>{
            state.shop=payload
        }
    }
})
export const {add} =todo.actions
export default todo.reducer